package com.nacos.utils;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;

import java.util.Properties;
import java.util.concurrent.Executor;

public class NacosConfigPublishExample {

    public static void main(String[] args) throws NacosException {
        String serverAddr = "localhost:8848"; // Nacos 服务器地址
        String dataId = "configServiceJson-dev.properties"; // 配置文件的dataId
        String group = "DEFAULT_GROUP"; // 配置文件的group

        Properties properties = new Properties();
        properties.put("serverAddr", serverAddr);
        properties.put("namespace", "229bd3af-0083-495a-a44c-774b2e45c7f1");
        ConfigService configService = NacosFactory.createConfigService(properties);

        boolean isPublishOk = configService.publishConfig(dataId, group, "content");
        System.out.println(isPublishOk);

//        boolean isRemoveOk = configService.removeConfig(dataId, group);
//        System.out.println(isRemoveOk);
    }
}